#include<stdio.h>
#include<string.h>
struct record{
	char username[11];
	char password[11];
} ;

void main()
{	struct record r1[100];
	int key1,key2,asval1,asval2;
	char ch,cr;
	int i,choice=1;
	i=0;
	char su[11];
	char sp[11];
	FILE *fp;
	fp=fopen("dsa.txt","r");
	if(fp==NULL)
	{	printf("no such file exists\n");
	  
	}
	else
	{	while(fscanf(fp,"%s %s",su,sp)!=EOF)
		{	ch=su[0];
			asval1=(int)ch;
			key1=asval1%10;
			if(strlen(r1[key1].username)==0)
			{	strcpy(r1[key1].username,su);
				strcpy(r1[key1].password,sp);
				
			}
			else
			
			{
				while(strlen(r1[key1].username)!=0)
				{	if(key1==100)
					{	key1=0;
					}
					else
					key1=key1+1;
				}
				strcpy(r1[key1].username,su);
				strcpy(r1[key1].password,sp);
			}			
		}
	}	
	char user[11];
	char pass[11];
		while(choice==1)
		{	if(i==3)
			{	printf("you have accessed 3 times now program needs to exit\n"); break;}
			printf("enter the username:\n");
    			scanf("%s",&user);
			cr=user[0];
			asval2=(int)cr;
			key2=asval2%10;
			printf("enter the password:\n");
    			scanf("%s",&pass);
			int j;
   			int t1=0;
			for(j=0;j<100;j++)
			{	if(strcmp(r1[key2].username,user)==0&&strcmp(r1[key2].password,pass)==0)
        			{    	t1=1;
	      				break;
				}
				else
				{	key2=key2+1;
				}
			}
			if(t1==1)
			{	printf("password matched\n");
			}
			else
			printf("record not found\n");
			i=i+1;
			printf("want to search more press 1 else press 0 to exit:\n");
			scanf("%d",&choice);
			
		}
	
	
}

